package com.welsy.authoring.business
{
	import com.welsy.authoring.model.CourseModelLocator;
	import com.welsy.authoring.vo.QuestionVO;
	import com.welsy.authoring.vo.course.ElementVO;
	import com.welsy.authoring.vo.course.pattern.*;
	
	[Bindable]
	public class ClosingTestElement implements IElement
	{
		//composition
		public var element:ElementVO = new ElementVO;
						 
		public var skipType:String = "0";
		
		public var questionWeightType:String = "0";
		
		public var passingCondition:String = "0";
		
		public var displayCorrected:String = "false";
	
	    public var displayFeedback:String = "false";
	    
	    public var displayCorrectAnswere:String = "false";
	    
	    public var traceConsultationTime:String = "false";
	    
	    public var consultationTimeLimit:int = 0;
	    
	    public var weight:int = 0;
	    
	    public var comparable:Boolean = false;
	    
	    private var myQuestionArray:Array = new Array();
	    	    	    
	    public function addQuestion (question:QuestionVO):void {
			myQuestionArray.push (question);
		}		
		
		public function getQuestion (index:int):QuestionVO {
			return myQuestionArray[index];
		}
	    		
		public function getQuestions ():Array {
			return myQuestionArray;
		}
		
		public function getQuestionsIndex ():int {
			return myQuestionArray.length;
		}		
		
		public function cleanQuestions ():void {
			myQuestionArray.length = 0;
		}
		
		public function WeightType():Boolean {
	      	if (this.questionWeightType == "1")
	      		return true;
			else
				return false;
	    } 
	    
	    public function enableItem():Boolean
		{	
			var model:CourseModelLocator = CourseModelLocator.getInstance()
					
			if ( (this.element.type == "0") && ((model.selectedCourse.course.state == CourseState.publish) || (model.selectedCourse.course.parentCourseId != "0")) )
				return false
		    else
		    	return true
		}
	}
}